import time
from autotest.testsuites.test_base import TestBase
from autotest.pageobjects.baidu_page import Cloud
import configparser
import os.path
config = configparser.ConfigParser()
path=os.path.dirname(os.path.abspath('.'))+'/autotest/config/'
config.read(path+'config.ini',encoding='utf-8')
print(config.sections())

class BaiduSearch(TestBase):

    def test_baidu_search(self):
        #这里一定要用test开头，把测试逻辑代码封装到一个test开头的方法里。
        input= Cloud(self.driver)
        # input.open('https://www.baidu.com/')
        #通过配置文件获取地址
        input.open(config.get('testServer','URL'))
        #取值方式或者这样
        # input.open(config["testServer"]["URL"])
        input.value_input('selenium')
        input.submit_btn()
        time.sleep(2)
        input.get_windows_img()#调用基类截图方法
        try:
            assert 'selenium' in 'selenium'
            print("test passed")
        except Exception as e:
            print("test failed",format(e))